﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;

namespace RobotGerchik.DataClass.BaseTransaqCalss
{

    /// <summary>
    /// Сделки
    /// Передается автоматически после установки соединения (для уже
    /// совершенных сделок), а так же по мере появления новых сделок.
    /// </summary>
    public class Deal : INotifyPropertyChanged
    {
        #region Private

        private int _secid;
        private long _tradeno;
        private long _orderno;
        private string _board;
        private string _seccode;
        private string _client;
        private string _buysell;
        private DateTime _time;
        private string _brokerref;
        private double _value;
        private double _comission;
        private double _price;
        private int _quantity;
        private long _currentpos;

        #endregion

        #region Public
        /// <summary>
        /// Идентификатор бумаги
        /// </summary>
        public int Secid
        {
            get { return _secid; }
            set
            {
                if (_secid != value)
                {
                    _secid = value;
                    RaisePropertyChanged("Secid");
                }
            }
        }

        /// <summary>
        /// Номер сделки на бирже
        /// </summary>
        public long Tradeno
        {
            get { return _tradeno; }
            set
            {
                if (_tradeno != value)
                {
                    _tradeno = value;
                    RaisePropertyChanged("Tradeno");
                }
            }
        }

        /// <summary>
        /// Номер заявки на бирже
        /// </summary>
        public long Orderno
        {
            get { return _orderno; }
            set
            {
                if (_orderno != value)
                {
                    _orderno = value;
                    RaisePropertyChanged("Orderno");
                }
            }
        }

        /// <summary>
        /// Идентификатор борда
        /// </summary>
        public string Board
        {
            get { return _board; }
            set
            {
                if (_board != value)
                {
                    _board = value;
                    RaisePropertyChanged("Board");
                }
            }
        }

        /// <summary>
        /// Код инструмента
        /// </summary>
        public string Seccode
        {
            get { return _seccode; }
            set
            {
                if (_seccode != value)
                {
                    _seccode = value;
                    RaisePropertyChanged("Seccode");
                }
            }
        }

        /// <summary>
        /// Идентификатор клиента
        /// </summary>
        public string Client
        {
            get { return _client; }
            set
            {
                if (_client != value)
                {
                    _client = value;
                    RaisePropertyChanged("Client");
                }
            }
        }

        /// <summary>
        /// B - покупка, S - продажа
        /// </summary>
        public string Buysell
        {
            get { return _buysell; }
            set
            {
                if (_buysell != value)
                {
                    _buysell = value;
                    RaisePropertyChanged("Buysell");
                }
            }
        }

        /// <summary>
        /// время сделки
        /// </summary>
        public DateTime Time
        {
            get { return _time; }
            set
            {
                if (_time != value)
                {
                    _time = value;
                    RaisePropertyChanged("Time");
                }
            }
        }

        /// <summary>
        /// примечание
        /// </summary>
        public string Brokerref
        {
            get { return _brokerref; }
            set
            {
                if (_brokerref != value)
                {
                    _brokerref = value;
                    RaisePropertyChanged("Brokerref");
                }
            }
        }

        /// <summary>
        /// объем сделки
        /// </summary>
        public double Value
        {
            get { return _value; }
            set
            {
                if (_value != value)
                {
                    _value = value;
                    RaisePropertyChanged("Value");
                }
            }
        }

        /// <summary>
        /// комиссия
        /// </summary>
        public double Comission
        {
            get { return _comission; }
            set
            {
                if (_comission != value)
                {
                    _comission = value;
                    RaisePropertyChanged("Comission");
                }
            }
        }

        /// <summary>
        /// цена
        /// </summary>
        public double Price
        {
            get { return _price; }
            set
            {
                if (_price != value)
                {
                    _price = value;
                    RaisePropertyChanged("Price");
                }
            }
        }

        /// <summary>
        /// количество лотов
        /// </summary>
        public int Quantity
        {
            get { return _quantity; }
            set
            {
                if (_quantity != value)
                {
                    _quantity = value;
                    RaisePropertyChanged("Quantity");
                }
            }
        }

        /// <summary>
        /// Текущая позиция по инструменту
        /// </summary>
        public long Currentpos
        {
            get { return _currentpos; }
            set
            {
                if (_currentpos != value)
                {
                    _currentpos = value;
                    RaisePropertyChanged("Currentpos");
                }
            }
        }
        #endregion

        #region event PropertyChangedEventHandler

        public event PropertyChangedEventHandler PropertyChanged;

        protected void RaisePropertyChanged(string propertyName)
        {
            var handler = PropertyChanged;
            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(propertyName));
            }
        }

        #endregion
    }
}
